package com.dangdang.action.order;

import com.dangdang.action.BaseAction;
import com.dangdang.service.OrderService;
import com.dangdang.service.ServiceFactory;
import com.dangdang.util.Constants;

/**
 * 删除订单控制层
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-3-21
 */
public class DeleteOrderAction extends BaseAction {

	private Integer orderId;

	private Integer[] orderIds;

	private OrderService orderService;

	public Integer getOrderId() {
		return orderId;
	}

	public void setOrderId(Integer orderId) {
		this.orderId = orderId;
	}

	public Integer[] getOrderIds() {
		return orderIds;
	}

	public void setOrderIds(Integer[] orderIds) {
		this.orderIds = orderIds;
	}

	/**
	 * 删除订单
	 * 
	 * @return
	 */
	public String execute() {
		orderService = ServiceFactory.getOrderService();
		orderService.deleteOrderById(orderId);
		return Constants.FORWARD_SUCCESS;
	}

	/**
	 * 删除所有的订单
	 * 
	 * @return
	 */
	public String deleteoAllOrder() {
		orderService = ServiceFactory.getOrderService();
		if (orderIds != null) {
			orderService.deleteAllOrderById(orderIds);
			return Constants.FORWARD_SUCCESS;
		}
		return Constants.FORWARD_SUCCESS;
	}
}
